// Copyright (C) joyinter
// All rights reserved.
// 
// Author : Jiang Li
// Date   : 2004-11-17

#ifndef __DB_SOURCESET_H_COMMON_SVR_BASE__
#define __DB_SOURCESET_H_COMMON_SVR_BASE__

#pragma once

#include "db_source.h"
#include "db_session.h"

namespace JoyServer
{

class CJoyServer;

class CJoyDbSourceSet
{
public:
    typedef CArray<CJoyDbSource> CSourceArray;
    CSourceArray   m_sources;
public:
    CJoyDbSourceSet(void);
    virtual ~CJoyDbSourceSet(void);

    CJoyDbSource& GetSource(UINT nId)
    {
        return m_sources[nId%m_sources.GetCount()];
    }

    bool Create(CJoyServer* pServer, CJoyDbSession& servSess, int nDBType);
    void Destroy();
};

class CJoyOServDbSourceSet : public CJoyDbSourceSet
{
protected:
public:
    CJoyOServDbSourceSet();
    virtual ~CJoyOServDbSourceSet();

    bool Create(CJoyServer* pServer, CJoyDbSession& servSess);
};

class CJoyOUserDbSourceSet : public CJoyDbSourceSet
{
protected:
public:
    CJoyOUserDbSourceSet();
    virtual ~CJoyOUserDbSourceSet();

    bool Create(CJoyServer* pServer, CJoyDbSession& servSess);
};

} // namespace JoyServer

#endif  // __DB_SOURCESET_H_COMMON_SVR_BASE__